#!/usr/bin/env bash

set -e -u -x
source ./tasks/helpers.sh

crane_version="0.20.1"
crane_hash="c394da2c1238b4c255cb517722a4e0925fdb4c3f1e9a3ae6ea2dd630201fac59"

download_arch="$TARGETARCH"
if [ "$TARGETARCH" == "amd64" ]; then
  download_arch="x86_64"
elif [ "$TARGETARCH" == "arm64" ]; then
  crane_hash="a941091345c7c411f7750575addf3d1c2d9b1214f0197ded78309f1daa59897f"
fi

task_working_dir
download "https://github.com/google/go-containerregistry/releases/download/v${crane_version}/go-containerregistry_Linux_${download_arch}.tar.gz" "sha256" "$crane_hash"
extract_download "go-containerregistry_Linux_${download_arch}.tar.gz"

install -D -m 755 "crane" "$DEV_INSTALL_PREFIX/bin/crane"

stamp
